<template>
  <div class="demo-image__preview">
  <el-image 
    style="width: 100px; height: 100px"
    :src="url" 
    :preview-src-list="fileList">
  </el-image>
</div>
</template>


<script>
import pictureApi from '@/api/dfs/picture'
  export default {
    data() {
      return {
      page:1,
      limit:20,
      fileList: [],
      pictureQuery:{},
        url: 'https://fuss10.elemecdn.com/8/27/f01c15bb73e1ef3793e64e6b7bbccjpeg.jpeg',
        // srcList: [
        //   'https://fuss10.elemecdn.com/8/27/f01c15bb73e1ef3793e64e6b7bbccjpeg.jpeg',
        //   'https://fuss10.elemecdn.com/1/8e/aeffeb4de74e2fde4bd74fc7b4486jpeg.jpeg'
        // ]
      }
    },
  created() {
    this.getList2()
  },
  methods: {
    /** 网安时情图片列表 */
    
    handleRemove(file,fileList) {
      const id = file.uid
      pictureApi.removeById(id)



      // this.fileList={}
      // this.$confirm('是否确认删除此图片asdfasdf?', '警告', {
      //   confirmButtonText: '确定',
      //   cancelButtonText: '取消',
      //   type: 'warning'
      // }).then(function() {
      //    const id = file.uid
      //   // return delNetSecurityImg(id)//删除图片
      //   console.log(id)
      //   return pictureApi.removeById(id)
      // }).then(response => {
      //   if (response.success) {
      //      this.fileList={}
      //     this.getList2()
      //     this.msgSuccess('删除成功')
      //   }
      // }).catch(() => {
      //   // this.fileList={}
      //   this.getList2()
      // })
    },
            removeDataById(id){
             this.$confirm('此操作将永久删除讲师记录, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
             teacher.deleteTeacherId(id)
            .then(response=>{//请求成功
                this.$message({
                     type: 'success',
                     message: '删除成功!'
                })
                this.getList()
            })
        })
        },

            //列表方法
        getList2(page = 1){
          // const token = getToken();
            // alert(token)获取token

          // this.pictureQuery.username=`admin`
            this.page = page
            // console.log(this.pictureQuery)
            pictureApi.listByUserId(this.page,this.limit,this.pictureQuery)
            .then(response=>{//请求成功
            // response接口返回的数据
                // console.log(response)
                // this.list = response.data.records
                // this.total = response.data.total
                const imgList = response.data.records
                for (let i = 0; i < imgList.length; i++) {
                  this.url = imgList[0].newFilename
                  this.fileList.push(
                   imgList[i].newFilename
                  )
                }                

                 console.log(this.fileList)  
                //  console.log(this.total) ;
            })
            .catch(error =>{//请求失败
                console.log("请求失败:"+error)
            })
        },

  }
}
</script>